home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 8
/
CU Amiga Magazine's Super CD-ROM 08 (1997)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1997-03].iso
/
c
/
makeindex
< prev
next >
Wrap
Text File
|
1996-11-01
|
6KB
|
179 lines
/* MakeIndex
Hacked by Andy Macklin to produce a sort of index of doc/guide files.
My version of grep uses the following syntax...
usage: grep [-[[AB] ]<num>] [-[CEFGVchilnqsvwx]] [-[ef]] <expr> [<files...>]
Requirements: grep
sort
copy
searchguide (optional)
same syntax as buildindex (optional)
*/
buildidx='Y' /*Change to 'Y' for an all in one script ;) */
SGUIDE='N' /*Change to 'Y' for an automatic search button in the docs guide file */
address command
Volume = left(pragma('D'),pos(':',pragma('D')))
/* defines and such */
/* GREP CALL */
GREPCALL = "grep"
/* GREP HELP CALL */
GREPHELP = "grep -h"
/* Where's the CUCD index? */
IDXLOC = Volume'CUCD.index'
/* Where's the finished guide to go to?*/
outfile = Volume'Docs.guide'
/* Path to MultiView */
MView = Volume'Utilities/MultiView'
/* Extensions to search for */
Extensions = 'guide|doc|dok|txt|text|asc|man|readme'
if buildidx='Y' then do
/* NB the column format is important for the sort fuction later */
'delete >NIL:' outfile /* Otherwise the guide will contain a reference to itself */
'list' Volume 'all files pat=~(#?.info) lformat "%-33N%P%N" to' IDXLOC
end
grepfile = "t:grepoutput." || Pragma("i")
agfile = "t:grepguide." || Pragma("i")
CR = d2c(10)
TAB = d2c(9)
/* setup the output file - we need this first so we can show errors in it */
IF Open(agfp,agfile,'w') = 0 THEN DO
SAY "Couldn't create amigaguide file ("||agfile||")"
EXIT 20
END
call writeln(agfp,'@DATABASE "CD docs"')
call writeln(agfp,'@REMARK created by Andys MakeIndex v2 :)')
call writeln(agfp,'')
call writeln(agfp,'@NODE Main "DOCS & GUIDES"')
call writeln(agfp,'')
/* Put a search button (needs searchguide in the CDs path) */
if SGUIDE='Y' then do
call writeln(agfp,'@{" Search " SYSTEM "RUN SearchGuide '||substr(outfile,pos(':',outfile)+1)||'" }')
call writeln(agfp,'')
end
SIGNAL ON FAILURE
ADDRESS COMMAND
'delete >NIL:' grepfile
do until Extensions = ''
parse var Extensions ext '|' Extensions
GREPCALL '-F .'ext IDXLOC '>>' grepfile
end
'rename' grepfile ' to ' grepfile||'.old'
'sort' grepfile||'.old' grepfile 'colstart 37'
SIGNAL OFF FAILURE
IF Open(grepfp,grepfile,'r') = 0 THEN DO
CALL HandleError("Couldn't open grep output file ("||grepfile||")","")
END
/*************************************************************************
** Format of Grep output
** =====================
**
**HTMLit!.guide CUCD4:Magazine/WiredWorld/HTMLit!/HTMLit!.guide
**DemosOfTheWorld.guide CUCD4:CUCD/Demos/DemosOfTheWorld/DemosOfTheWorld.guide
**mc12.guide CUCD4:CUCD/Demos/Malevolent_Creations/mc12.guide
**iml-Feb71.guide CUCD4:CUCD/Graphics/Imagine/iml-Feb71.guide
**Dust.guide CUCD4:CUCD/Graphics/Imagine/Dust/Docs/Dust.guide
**DustEnglish.guide CUCD4:CUCD/Graphics/Imagine/Dust/Docs/DustEnglish.guide
**IM_Organizer.guide CUCD4:CUCD/Graphics/Imagine/IM_Organiser/IM_Organizer.guide
**TextureStudio.guide CUCD4:CUCD/Graphics/Imagine/TextureStudio/Docs/TextureStudio.guide
**ncFTPevents.guide CUCD4:CUCD/Online/ThorStuff/Programs/ncFTPevents/Thor/docs/ncFTPevents.guide
**
****************************************************************************/
line = ReadLn(grepfp)
IF EOF(grepfp) THEN DO
call close(grepfp)
say 'No files found'
exit 10
END
CALL Pragma('W','n') /* turn off dos requesters */
DO WHILE ~EOF(grepfp)
/* START BY LOOKING FOR FILENAMES */
currentfile = Strip(Left(line,Length(Word(line,1))),"B")
location = strip(right(line,length(line)-length(word(line,1))),"B")
if right(currentfile,5) ='guide' then
do
node='/main'
action='link "'
end
else
do
node=''
action='system "'MView' '
end
endif
call writeln(agfp,'@{" 'currentfile left('',33-length(currentfile))' "' action||location||node'" } 'substr(location,pos(':',location)+1))
line = ReadLn(grepfp)
END
call WriteLn(agfp,'@ENDNODE')
call Close(grepfp)
call Close(agfp)
CALL Pragma('W','w') /* turn dos requesters back on */
address command
'copy' agfile outfile
'delete >NIL:' grepfile
'delete >NIL:' grepfile||'.old'
'delete >NIL:' agfile
EXIT
FAILURE:
ERROR:
errRC = RC
CALL Close(grepfp)
CALL HandleError("Grep Failure:"|| CR || " " || FullCommand ,grepfile)
EXIT
/***************************************************/
HandleError: PROCEDURE EXPOSE agfp grepfile agfile grephelp
ErrorText = arg(1)
ErrorFile = arg(2)
call writeln(agfp,'-=-=-=-=-=-=-=-=-= E R R O R =-=-=-=-=-=-=-=-=-')
call writeln(agfp,ErrorText)
call writeln(agfp,' ')
IF (ErrorFile~="" & Exists(ErrorFile)) THEN DO
call writeln(agfp,"Response:")
ADDRESS COMMAND GREPHELP '>>'ErrorFile
Open('errorfp',ErrorFile,'r')
DO WHILE ~EOF('errorfp')
call writeln(agfp," " || ReadLn('errorfp'))
END
call close('errorfp')
END
call writeln(agfp,"")
call writeln(agfp,"Current Path:")
call writeln(agfp," "||Pragma("D"))
call writeln(agfp,'@ENDNODE')
call close(agfp)
IF Exists(grepfile) THEN Delete(grepfile)
Delete(agfile)
EXIT 20
RETURN